//
//  ReviewView.m
//  HTT
//  总结view
//  Created by admin on 15/12/1.
//  Copyright © 2015年 nit. All rights reserved.
//

#import "ReviewView.h"
#import "CourseRecordDetailModel.h"
@interface ReviewView()
@property (nonatomic, retain) CourseRecordDetailModel *courseRecordDetail;

@property (nonatomic, retain) UILabel *summaryLabel;
@end
@implementation ReviewView
- (id)init{
    self = [super init];
    if (self) {
        [self _initView];
    }
    return self;
}
- (void)_initView{
    [self setBackgroundColor:[UIColor whiteColor]];
    
    _summaryLabel = [self getNormolLabel];
    _summaryLabel.textAlignment = _TEXT_ALIGN_LEFT;
    [self addSubview:_summaryLabel];
}
- (void)setViewData:(id)viewData{
    _courseRecordDetail = viewData;
    [self.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        [obj removeFromSuperview];
    }];
    if ([_courseRecordDetail.cgcStatus integerValue] == 0 || [_courseRecordDetail.cgcStatus integerValue] == 1) {
        //未达到总结的步奏
        [self setFrame:CGRectMake(0, 0, 0, 0)];
    }else{
        if (_courseRecordDetail.crTchSummary.length == 0) {
//            //未总结 需要总结
//            UIButton *zjBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 40)];
//            [zjBtn setTitle:@"总结" forState:UIControlStateNormal];
//            [zjBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
//            [zjBtn addTarget:self action:@selector(doSummaryAction) forControlEvents:UIControlEventTouchUpInside];
//            [self addSubview:zjBtn];
            [self setFrame:CGRectMake(0, 0, ScreenWidth, 0)];
        }else{
            [self _initDetail];
        }
    }
}
- (void)_initDetail{
    UILabel *titleLabel = [self getNormolLabel];
    titleLabel.frame = CGRectMake(10, 5, ScreenWidth-20, 30);
    titleLabel.text = @"教师总结";
    titleLabel.font = [UIFont systemFontOfSize:20];
    titleLabel.textAlignment = _TEXT_ALIGN_LEFT;
    [self addSubview:titleLabel];
    
    UIImageView *lineImage = [[UIImageView alloc] initWithFrame:CGRectMake(10, 40, ScreenWidth - 20, 1)];
    lineImage.backgroundColor = RGBCOLOR(230, 230, 230, 1);
    [self addSubview:lineImage];
    
    _summaryLabel.text = _courseRecordDetail.crTchSummary;
    CGSize summarySize = [_summaryLabel.text textSizeWithFont:_summaryLabel.font constrainedSize:CGSizeMake(ScreenWidth -20, ScreenHeihgt)];
    _summaryLabel.frame = CGRectMake(10, 50, ScreenWidth - 20, summarySize.height);
    [self addSubview:_summaryLabel];
    
    [self setFrame:CGRectMake(0, 0, ScreenWidth, CGRectGetMaxY(_summaryLabel.frame) + 10)];
    
}
- (void)doSummaryAction{
    if (self.delegate) {
        [self.delegate toSummaryAction];
    }
}
-(UILabel *)getNormolLabel{
    UILabel *label = [[UILabel alloc] init];
    label.textAlignment = _TEXT_ALIGN_CENTER;
    label.font = [UIFont systemFontOfSize:15];
    label.textColor = RGBCOLOR(0, 0, 0, 0.7);
    label.numberOfLines = 0;
    return label;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
